﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Mvc;

namespace IInject.Web.Mvc
{
	public class IInjectDependencyResolver : IDependencyResolver
	{
		public IInjectDependencyResolver(IContainer container)
		{
			Container = container;
		}

		public IContainer Container { get; set; }

		public object GetService(Type serviceType)
		{
			try
			{
				return Container.Get(serviceType);
			}
			catch (Exception ex)
			{
				return null;
			}
		}

		public IEnumerable<object> GetServices(Type serviceType)
		{
			try
			{
				return Container.GetAll(serviceType);
			}
			catch (Exception ex)
			{
				return null;
			}
		}
	}
}
